package com.top10.utils;

import com.alibaba.fastjson.JSON;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.util.Map;

public class QQUtil {
	public static Map<String,String> getUserInfo(String access_token, String openid) throws Exception{
		HttpClient httpclient =  HttpClients.createDefault();
		String smsUrl="https://graph.qq.com/user/get_user_info?access_token="+ access_token +"oauth_consumer_key=12345&openid="+ openid;
		HttpGet httpGet = new HttpGet(smsUrl);
		String strResult = "";

		HttpResponse response = httpclient.execute(httpGet);
		if (response.getStatusLine().getStatusCode() == 200) {
			/*读返回数据*/
			strResult = EntityUtils.toString(response
					.getEntity(),"UTF-8");
		}
		Map resultMap = (Map) JSON.parse(strResult);
		return resultMap;
	}
}
